package com.xgpro.mobile.studycentre.controller;

import com.xgpro.common.exceptions.BusinessRuntimeException;
import com.xgpro.common.results.ResponseResult;
import com.xgpro.domain.studycentre.vo.TeaFront;
import com.xgpro.mobile.studycentre.service.TeaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tx
 * @version 1.0
 * @date 2019/10/11 22:32
 */

@RestController
@RequestMapping("/tea")
@CrossOrigin(allowCredentials="true")
public class TeaController {
    @Autowired
    private TeaService teaService;

    /**
     * 内外部导师列表
     * @param teaFront
     * @return
     */
    @RequestMapping("/qryTeaSimple")
    public ResponseResult qryTeaSimple(@RequestBody TeaFront teaFront){
           return ResponseResult.ok(teaService.qryTeaSimple(teaFront));
    }

    /**
     * 内外部导师详情
     * @param id
     * @return
     */
    @RequestMapping("/qryTeaInfoById")
    public ResponseResult qryTeaInfoById(Integer id){
        return ResponseResult.ok(teaService.qryTeaInfoById(id));
    }

    /**
     * 设置是否推荐
     * @param id
     * @return
     */
    @RequestMapping("/setGoodTea")
    public ResponseResult setGoodTea(Integer id,Integer isGood  ){
        try{
            return ResponseResult.ok(teaService.setGoodTea(id ,isGood));
        }catch (BusinessRuntimeException e){
            return ResponseResult.failure(e.getErrorCode(),e.getMessage());
        }

    }

    /**
     * 首页讲师风采
     * @return
     */
    @RequestMapping("/qryGoodTea")
    public ResponseResult qryGoodTea(){
        return ResponseResult.ok(teaService.qryGoodTea());
    }



}
